home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / get3270.zip / GET3270.C < prev    next >
C/C++ Source or Header  |  1993-01-04  |  3KB  |  117 lines

  1. #include <stdio.h>
  2. #include <dos.h>
  3. #include <ctype.h>
  4.  
  5.  
  6. int api_function;
  7. int api_length;
  8. int api_return;
  9. char api_string[255];
  10.  
  11. main(argc,argv)
  12.  
  13.     int  argc;
  14.     char *argv[];
  15.  
  16. {
  17.     int  i;
  18.     int  j;
  19.  
  20.     char pspace[2000];
  21.  
  22.  
  23.     int  get_pspace(char *);
  24.     int  display_pspace(char *);
  25.  
  26.  
  27.     /*  reset hllapi  */
  28.  
  29.     api_function = 21;
  30.     HLLC(&api_function,api_string,&api_length,&api_return);
  31.     if ( api_return == 9 ) {
  32.         fprintf(stderr,"\nError - system cannot be reset.\n\n");
  33.         fprintf(stderr,"Probable cause - EEHLLAPI not loaded\n\n");
  34.         fprintf(stderr,"Press the space bar to continue.....");
  35.         getch();
  36.         return(api_return);
  37.         }
  38.  
  39.  
  40.     /*  connect to host system  */
  41.  
  42.     api_function = 1;
  43.     strcpy(api_string,"E\0");
  44.     api_length = 1;
  45.     HLLC(&api_function,api_string,&api_length,&api_return);
  46.     if ( api_return != 0 )  {
  47.         fprintf(stderr,"\nError - could not connect to host session, rc= %4d\n\n",api_return);
  48.         fprintf(stderr,"Probable cause - EEHLLAPI not loaded\n\n");
  49.         fprintf(stderr,"Press the space bar to continue.....");
  50.         getch();
  51.         return(api_return);
  52.         }
  53.  
  54.     /*  We're talking to the mainframe session - get the presentation space
  55.         and write it to STDOUT.
  56.     */
  57.  
  58.  
  59.     get_pspace(pspace);
  60.     display_pspace(pspace);
  61.  
  62.  
  63.     /* Disconnect presentation space before quitting  */
  64.  
  65.     api_function = 2;
  66.     HLLC(&api_function,api_string,&api_length,&api_return);
  67.  
  68.  
  69. }    /* main  */
  70.  
  71.  
  72.  
  73.  
  74.  
  75. int get_pspace(p_space)
  76.  
  77.   /*  return the entire contents of the presentation space into a passed
  78.        string.  The string must be preallocated to at least 1920.  The
  79.        function returns the value of the return string     */
  80.  
  81.     char *p_space;
  82.  {
  83.  
  84.  
  85.     api_function = 8;
  86.     api_length = 1920;
  87.     api_return = 1;
  88.     HLLC(&api_function,p_space,&api_length,&api_return);
  89.  
  90.     return(api_return);
  91.  
  92.   }
  93.  
  94.  
  95.  display_pspace(p_space)
  96.  
  97.     /*  display the current contents of the presentation space
  98.         on the screen.  Normal usage is:
  99.                     get_pspace(pspace);
  100.                     display_pspace(pspace);
  101.                     getch();
  102.  
  103.         The screen displayed on the PC should be identical to the
  104.         mainframe screen.         */
  105.  
  106.     char *p_space;
  107.  
  108.     {
  109.         int j;
  110.  
  111.         printf("\n");
  112.         for (j=0;j<1920;j++) printf("%c",p_space[j]);
  113.         printf("\n\n");
  114.     }
  115.  
  116.  
  117.